home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib / c / bsearch.man < prev    next >
Encoding:
Text File  |  1989-03-22  |  1.3 KB  |  45 lines

  1. '\" Copyright 1989 Regents of the University of California
  2. '\" Permission to use, copy, modify, and distribute this
  3. '\" documentation for any purpose and without fee is hereby
  4. '\" granted, provided that this notice appears in all copies.
  5. '\" The University of California makes no representations about
  6. '\" the suitability of this material for any purpose.  It is
  7. '\" provided "as is" without express or implied warranty.
  8. '\" 
  9. '\" $Header: /sprite/src/lib/c/stdlib/RCS/bsearch.man,v 1.1 89/02/18 20:38:40 rab Exp $
  10. '/" 
  11. .so \*(]ltmac.sprite
  12. .HS bsearch lib
  13. .BS
  14. .SH NAME
  15. bsearch \- Binary search
  16. .SH SYNOPSIS
  17. .nf
  18. \fBvoid *bsearch(key, base, n, size, cmp)
  19. .SH ARGUMENTS
  20. .AS size_t base
  21. .AP void *key;
  22. Pointer to the object being searched for.
  23. .AP void *base;
  24. Pointer to the base of the array to search.
  25. .AP size_t n;
  26. Number of items in the array.
  27. .AP size_t size;
  28. Size of each item.
  29. .AP int (*cmp)();
  30. Function to compare two items.
  31. .BE
  32.  
  33. .SH DESCRIPTION
  34. .PP
  35. \fBBsearch\fR searches \fBbase[0] ... base[n - 1]\fR for an item
  36. that matches \fB*key\fR.  The function \fBcmp\fR must return
  37. negative if its first argument (the search key) is less than
  38. its second (a table entry), zero if equal, and positive if greater.
  39. Items in the array \fBbase\fR must be in ascending order.  \fBbsearch\fR
  40. returns a pointer to a matching item, or \fBNULL\fR if none exits.
  41.  
  42. .SH KEYWORDS
  43. search
  44.  
  45.